package com.ruoyi.business.controller;

import com.ruoyi.business.domain.BusCheck;
import com.ruoyi.business.service.BusCheckService;
import com.ruoyi.business.service.BusRentService;
import com.ruoyi.business.vo.CheckVo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 内容:
 * 作者: cy
 */
@RestController
@Api(tags = "汽车入库管理接口")
@RequestMapping("business/backCar")
public class BackCarController extends BaseController {

   @Autowired
   private BusRentService busRentService;
   @Autowired
   private BusCheckService busCheckService;

   /**
    * 1.接收一个出租单号
    * 2.查询rent表 判断
    * 3.组装数据返回(生成检查单号，车辆信息，客户信息 出租信息)
    *
    * @param rentSn
    * @return
    */
   @GetMapping("checkRentSn")
   @ApiOperation("根据出租单号查询相关信息")
   public AjaxResult checkRentSn(String rentSn){
      CheckVo checkVo = busRentService.checkRentSn(rentSn);
      return AjaxResult.success(checkVo);
   }
   @PostMapping("doBackCar")
   @ApiOperation("汽车入库")
   public AjaxResult doBackCar(@RequestBody BusCheck busCheck){
      LoginUser loginUser = getLoginUser();
      Boolean flag = busCheckService.doBackCar(busCheck,loginUser);
      return AjaxResult.success(flag ? "车辆入库成功": "车辆入库失败,请联系管理员");
   }

}
